<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            background-color: #f00;
            margin: 50px;
        }

        body {
            width: 3000px;
            height: 3000px;
        }
    </style>
</head>

<body>

    <div id="a"></div>

    <script>




        a.onclick = function (e) {
            console.log(e.clientX, e.clientY);   // 鼠标距离可视窗口的坐标
            console.log(e.pageX, e.pageY);    // 鼠标距离页面的坐标
            console.log(e.x, e.y);    // x y 是clientX/Y 的简写
            console.log(e.offsetX, e.offsetY);    // 鼠标距离目标源的坐标
        }

    </script>

</body>

</html>